<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
$serverInfo = $BigDaddyData->GetServerInfoByID($_REQUEST["serverID"]);

if ($type=="edit")
{
	$smInfo = $BigDaddyData->GetServerModuleInfoByModuleID($_REQUEST["ID"]);
	$tableWidth="1000";
}
else
{
	$tableWidth="500";
}

?>
<form method="post" action="/server/query_servermod.php" name="serverform" id="serverform">

<table border="0" cellpadding="5" cellspacing="1" width="<?=$tableWidth;?>">
<tr valign="top">
<td>

<table border="0" cellpadding="5" cellspacing="1" width="500" class="formtable">
<?
if ($type=="addnew")
{
?>
<tr valign="top">
	<td class="formfielddesc">Module:<br />
		<span class="required">{required}</span></td>
	<td class="formfield">
		<select name="modID" size="1" class="selectfield">
		<?
		
		$aModules = $BigDaddyData->GetModules();

		foreach ($aModules as $nIndex => $row)
		{
			if ($smInfo["moduleID"]==$row["ID"])
			{
				$s=" selected";
			}
			else
			{
				$s="";
			}
		?>
			<option value="<?=$row["ID"];?>"<?=$s;?>><?=$row["name"];?></option>
		
		<?
		}
		?>
		</select>
	</td>
</tr>
<?
}
else
{
?>
<tr valign="top">
	<td class="formfielddesc">Module:<br />
		</td>
	<td class="formfield">
		<?=$smInfo["module_name"];?>
	</td>
</tr>


<?
}
?>
<tr valign="top">
	<td class="formfielddesc">INI File:<br />
	<span class="required">{required}</span></td>
	<td class="formfield">
		<select name="iniID" size="1" class="selectfield">
		<?
		
		$aIniFiles = $BigDaddyData->GetIniFiles();
				
		foreach ($aIniFiles as $nIndex => $row)
		{
			if ($smInfo["iniID"]==$row["ID"])
			{
				$s=" selected";
			}
			else
			{
				$s="";
			}
		?>
			<option value="<?=$row["ID"];?>"<?=$s;?>><?=$row["name"];?></option>
		
		<?
		}
		?>
		</select>
	</td>
</tr>
<tr valign="top">
	<td class="formfielddesc">Module Parameters<br />
	</td>
	<td class="formfield">
		<input name="parameters" class="textfield" type="text" value="<?=$smInfo["parameters"];?>" />
	
	</td>
</tr>
<tr valign="top">
	<td class="formfielddesc" colspan="2"><b>Warning Level Values</b><br />
	These take different meanings depending on the ini/module. Some will require escalation and will need end levels,
	some only reqire a start level as there is no escalation
	</td>
</tr>
<tr valign="top">
	<td class="formfielddesc">Start Level:<br />
	<span class="required">{required}</span></td>
	<td class="formfield">
		<select name="mon_startlevel" size="1" class="selectfield">
		<?
		for ($i=1; $i<6; $i++)
		{
			if ($smInfo["mon_startlevel"]==$i)
			{
				$s=" selected";
			}
			else
			{
				$s="";
			}
		?>
			<option value="<?=$i;?>"<?=$s;?>><?=$i;?></option>
		
		<?
		}
		?>
		</select>
	</td>
</tr>
<tr valign="top">
	<td class="formfielddesc">End Level:</td>
	<td class="formfield">
		<select name="mon_endlevel" size="1" class="selectfield">
		<option value="0">Escalate All Levels</option>
		<?
		for ($i=1; $i<6; $i++)
		{
			if ($smInfo["mon_endlevel"]==$i)
			{
				$s=" selected";
			}
			else
			{
				$s="";
			}
		?>
			<option value="<?=$i;?>"<?=$s;?>><?=$i;?></option>
		
		<?
		}
		?>
		</select>
	</td>
</tr>
<tr valign="top">
	<td class="formfielddesc" colspan="2"><b>Only For Modules Reporting Non-Boolean Values</b><br />
	Please read the documentation for each module and enter the information as appropriate
	</td>
</tr>

<tr valign="top">
	<td class="formfielddesc">Non-Boolean Warning Threshold<br />
	</td>
	<td class="formfield">
		<input name="lastreport_threshold" class="textfield" type="text" value="<?=$smInfo["lastreport_threshold"];?>" />
	
	</td>
</tr>
</table>
</td>

<?
if ($type=="edit")
{
?>

<td>

<table border="0" cellpadding="5" cellspacing="1" width="500" class="formtable">
<tr valign="top">
	<td class="formfielddesc">Current Info<br /></td>
</tr>
<tr>
<td class="formfield">
	Status:
	<?
	switch($smInfo["active"])
	{
		case 0:
			echo "Inactive";
		break;
		case 1:
			echo "Active";
		break;
		case 2:
			echo "Delayed";
		break;
	}
	
	?>
	<br />
	<?
	if ($smInfo["active"]==2)
	{
	?>
	Delayed Until:
	<?
	echo get_time_str($smInfo["delayed_until"], 2);
	?>
	<br />
	<?
	}
	?>
	<?
	if ($smInfo["mon_currentlevel"]>0)
	{
	?>
	Current Level: <?=$smInfo["mon_currentlevel"];?><br />
	<?
	}
	?>
	<?
	if ($smInfo["mon_currentlevelstart"]>0)
	{
	?>
	Current Level Started: <?=get_time_str($smInfo["mon_currentlevelstart"], 2);?><br />
	<?
	}
	?>
	<?
	if ($smInfo["mon_lastcheck"]>0)
	{
	?>
	Last Time Action Performed: <?=get_time_str($smInfo["mon_lastcheck"], 2);?><br />
	<?
	}
	?>
	<?
	if ($smInfo["mon_lastreport"]>0)
	{
	?>
	Module Last Reported: <?=get_time_str($smInfo["mon_lastreport"], 2);?><br />
	<?
	}
	?>
	<?
	if ($smInfo["lastreport"]!="")
	{
	?>
	Last Report: <?=$smInfo["lastreport"];?><br />
	<?
	}
	?>
</td>
</tr>
</table>

<?
if ($_SESSION["runModule"][$smInfo["ID"]] != "" )
{
?>

<table border="0" cellpadding="5" cellspacing="1" width="500" class="formtable">
<tr valign="top">
	<td class="formfielddesc">Run Info<br /></td>
</tr>
<tr>
<td class="formfield">
	Module Reported: <?=$_SESSION["runModule"][$smInfo["ID"]];?>
</td>
</tr>
</table>


<?
unset($_SESSION["runModule"]);
}
?>

</td>

<?
}
?>



</tr>
<tr valign="top">
	<td class="formfielddesc" colspan="2">
	<div align="center"><?
	if ($type=="addnew")
	{
	?>
		<input type="hidden" name="action" value="addmod" />
		<input type="hidden" name="serverID" value="<?=$_REQUEST["serverID"];?>" />
	<?
	}
	
	if ($type=="edit")
	{
	?>
		<input type="hidden" name="action" value="editmod" />
		<input type="hidden" name="ID" value="<?=$_REQUEST["ID"];?>" />
		<input type="hidden" name="serverID" value="<?=$_REQUEST["serverID"];?>" />
		<input type="hidden" name="modID" value="<?=$_REQUEST["modID"];?>" />
	<?
	}
	?></div>
	
	</td>
</tr>
</table>

<br />




</form>
